package  main

import (

	"fmt"
	"time"
	"os"
	"strconv"
	"runtime"
)


type SocketResponse struct {
	data      string
	response  string
	err       error
}

func main() {

	runtime.GOMAXPROCS(runtime.NumCPU())
	start:=time.Now().Unix()
	if len(os.Args) < 4 {
		fmt.Fprintf(os.Stderr, "Usage:%s  host:port connections send_times packet_type ", os.Args[0])
		os.Exit(1)
	}
	go end_hook( start )
	packet_type := "str"
	if( len(os.Args)>4 ){
		packet_type =  string( os.Args[4] )
	}
	fmt.Println( " packet_type : ", packet_type )
	var results []*SocketResponse
	num, _ := strconv.ParseInt(os.Args[2], 10, 32)
	if( packet_type=="json"){
		results = asyncReqJson( createReqJsonData(num) )
	}
	if ( packet_type=="str"){
		results = asyncReqStrSplit( createReqStrData(num) )
	}

	if( packet_type=="ws" ) {
		results = asyncReqStrSplitWs( createReqStrData(num) )
	}
	//log.Println( "urls:" ,urls  )
	i:=0
	for _, result := range results {
		i++
		fmt.Printf( "%d result length: %d\n",i,  len(result.data) )
	}

	fmt.Printf( " result num: %d\n",  len(results) )

	select{}
}



